#pragma once

#include <cmath>

class Mathf
{
private:
    Mathf() = delete;
    void operator=(const Mathf &mathf) = delete;
    Mathf(const Mathf &mathf) = delete;

public:
    static double Pi;      // Π
    static double c;       // 光速
    static double uGPS;    // GPS下地球引力常数GM
    static double uBDS;    // BDS下地球引力常数GM
    static double omgeGPS; // GPS下地球自转角速度
    static double omgeBDS; // BDS下地球自转角速度

    static double Abs(double value);
    static int Abs(int value);
    static float Abs(float value);
    static double Sin(double angle);
    static double Cos(double angle);
    static double Tan(double angle);
    static double Sqrt(double value);
    static double Pow(double base, double exponent);
    static double Min(double a, double b);
    static double Max(double a, double b);
    static double Arccos(double x);
    static double Arcsin(double x);
    static double Arctan(double x, double y);
    static double Arctan(double x);
    static int Floor(double value);
    static double Exp(double x);
    static void SplitDouble(double value, int* integerPart, double* fractionalPart);
    static double Normalize(double value);
};

double Mathf::Pi = 3.1415926535897932384626433832795;
double Mathf::c = 299792458;
double Mathf::omgeBDS = 7.2921150E-5;
double Mathf::omgeGPS = 7.2921151467E-5;
double Mathf::uGPS = 3.986005E14;
double Mathf::uBDS = 3.986004418E14;

double Mathf::Abs(double value)
{
    return fabs(value);
}

int Mathf::Abs(int value)
{
    return abs(value);
}

float Mathf::Abs(float value)
{
    return fabsf(value);
}

double Mathf::Sin(double angle)
{
    return sin(angle);
}

double Mathf::Cos(double angle)
{
    return cos(angle);
}

double Mathf::Tan(double angle)
{
    return tan(angle);
}

double Mathf::Sqrt(double value)
{
    return sqrt(value);
}

double Mathf::Pow(double base, double exponent)
{
    return pow(base, exponent);
}

double Mathf::Min(double a, double b)
{
    return (a < b) ? a : b;
}

double Mathf::Max(double a, double b)
{
    return (a > b) ? a : b;
}

double Mathf::Arccos(double x)
{
    return acos(x);
}

double Mathf::Arcsin(double x)
{
    return asin(x);
}

double Mathf::Arctan(double x, double y)
{
    return atan2(y, x);
}

double Mathf::Arctan(double x)
{
    return atan(x);
}

int Mathf::Floor(double value)
{
    return floor(value);
}

double Mathf::Exp(double x)
{
    return exp(x);
}

void Mathf::SplitDouble(double value, int* integerPart, double* fractionalPart)
{
    *integerPart = static_cast<int>(value);
    *fractionalPart = value - *integerPart;
}

// 保留四位小数
double Mathf::Normalize(double x)
{
    return std::round(x*10000)/10000;
}